﻿using System;
using System.Runtime.InteropServices;

namespace Microsoft.Win32
{
	internal static partial class NativeMethods
	{
		[Flags]
		public enum CommonControlClass
		{
			ListView = 0x00000001, // listview, header
			TreeView = 0x00000002, // treeview, tooltips
			Bars = 0x00000004, // toolbar, statusbar, trackbar, tooltips
			Tab = 0x00000008, // tab, tooltips
			UpDown = 0x00000010, // updown
			ProgressBar = 0x00000020, // progress
			HotKey = 0x00000040, // hotkey
			Animate = 0x00000080, // animate
			AllWin95 = 0x000000FF,
			Date = 0x00000100, // month picker, date picker, time picker, updown
			ComboBoxEx = 0x00000200, // comboex
			Rebar = 0x00000400, // rebar (coolbar) control
			IPAddress = 0x00000800,
			Pager = 0x00001000,   // page scroller
			NativeFontControl = 0x00002000,   // native font control
			Standard = 0x00004000,
			Hyperlink = 0x00008000,
		}

		[DllImport("comctl32.dll")]
		private static extern bool InitCommonControlsEx(INITCOMMONCONTROLSEX icc);

		[StructLayout(LayoutKind.Sequential)]
		private class INITCOMMONCONTROLSEX
		{
			public int dwSize = Marshal.SizeOf(typeof(INITCOMMONCONTROLSEX));
			public int dwICC;
		}

		public static bool InitCommonControlsEx(CommonControlClass ccc)
		{
			var icc = new INITCOMMONCONTROLSEX() { dwICC = (int)ccc };
			return InitCommonControlsEx(icc);
		}
	}
}
